export const setInitMenuCurrent = (tree: any[]): any | void => {
  let menupath: any[] = [];
  function playLoop(tree: any[]): string | void {
    if (tree && tree[0].children) {
      menupath.push(tree[0].menuFolderId);
      return playLoop(tree[0].children);
    } else {
      menupath.push(tree[0].menuFolderId);
      return tree[0].menuFolderId
    }
  }
  return {
    curr: playLoop(tree),
    pathary: menupath
  }
};

export const folderIdToObj = (currId: string, idary: string[], tree: any[]): any | void => {
  let menupathobj: any[] = [];
  let curr: any;
  function playLoop(tree: any[]): string | void {
    tree.filter(function (item: any) {
      if (item && item.menuFolderId === currId) {
        menupathobj.push(item);
        curr = item;
      } else {
        if (tree && item.children) {
          menupathobj.push(item);
          playLoop(item.children);
        }
      }
    })
  }
  playLoop(tree)
  if (!curr) {
    console.warn("无此菜单！")
  }
  return {
    curr: curr,
    pathary: menupathobj
  }
};